1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module gtk.ProgressBar; 26 27 private import glib.ConstructionException; 28 private import glib.Str; 29 private import glib.c.functions; 30 private import gobject.ObjectG; 31 private import gtk.OrientableIF; 32 private import gtk.OrientableT; 33 private import gtk.Widget; 34 private import gtk.c.functions; 35 public import gtk.c.types; 36 37 38 /** 39 * `GtkProgressBar` is typically used to display the progress of a long 40 * running operation. 41 * 42 * It provides a visual clue that processing is underway. `GtkProgressBar` 43 * can be used in two different modes: percentage mode and activity mode. 44 * 45 *  46 * 47 * When an application can determine how much work needs to take place 48 * (e.g. read a fixed number of bytes from a file) and can monitor its 49 * progress, it can use the `GtkProgressBar` in percentage mode and the 50 * user sees a growing bar indicating the percentage of the work that 51 * has been completed. In this mode, the application is required to call 52 * [method@Gtk.ProgressBar.set_fraction] periodically to update the progress bar. 53 * 54 * When an application has no accurate way of knowing the amount of work 55 * to do, it can use the `GtkProgressBar` in activity mode, which shows 56 * activity by a block moving back and forth within the progress area. In 57 * this mode, the application is required to call [method@Gtk.ProgressBar.pulse] 58 * periodically to update the progress bar. 59 * 60 * There is quite a bit of flexibility provided to control the appearance 61 * of the `GtkProgressBar`. Functions are provided to control the orientation 62 * of the bar, optional text can be displayed along with the bar, and the 63 * step size used in activity mode can be set. 64 * 65 * # CSS nodes 66 * 67 * ``` 68 * progressbar[.osd] 69 * ├── [text] 70 * ╰── trough[.empty][.full] 71 * ╰── progress[.pulse] 72 * ``` 73 * 74 * `GtkProgressBar` has a main CSS node with name progressbar and subnodes with 75 * names text and trough, of which the latter has a subnode named progress. The 76 * text subnode is only present if text is shown. The progress subnode has the 77 * style class .pulse when in activity mode. It gets the style classes .left, 78 * .right, .top or .bottom added when the progress 'touches' the corresponding 79 * end of the GtkProgressBar. The .osd class on the progressbar node is for use 80 * in overlays like the one Epiphany has for page loading progress. 81 * 82 * # Accessibility 83 * 84 * `GtkProgressBar` uses the %GTK_ACCESSIBLE_ROLE_PROGRESS_BAR role. 85 */ 86 public class ProgressBar : Widget, OrientableIF 87 { 88 /** the main Gtk struct */ 89 protected GtkProgressBar* gtkProgressBar; 90 91 /** Get the main Gtk struct */ 92 public GtkProgressBar* getProgressBarStruct(bool transferOwnership = false) 93 { 94 if (transferOwnership) 95 ownedRef = false; 96 return gtkProgressBar; 97 } 98 99 /** the main Gtk struct as a void* */ 100 protected override void* getStruct() 101 { 102 return cast(void*)gtkProgressBar; 103 } 104 105 /** 106 * Sets our main struct and passes it to the parent class. 107 */ 108 public this (GtkProgressBar* gtkProgressBar, bool ownedRef = false) 109 { 110 this.gtkProgressBar = gtkProgressBar; 111 super(cast(GtkWidget*)gtkProgressBar, ownedRef); 112 } 113 114 // add the Orientable capabilities 115 mixin OrientableT!(GtkProgressBar); 116 117 118 /** */ 119 public static GType getType() 120 { 121 return gtk_progress_bar_get_type(); 122 } 123 124 /** 125 * Creates a new `GtkProgressBar`. 126 * 127 * Returns: a `GtkProgressBar`. 128 * 129 * Throws: ConstructionException GTK+ fails to create the object. 130 */ 131 public this() 132 { 133 auto __p = gtk_progress_bar_new(); 134 135 if(__p is null) 136 { 137 throw new ConstructionException("null returned by new"); 138 } 139 140 this(cast(GtkProgressBar*) __p); 141 } 142 143 /** 144 * Returns the ellipsizing position of the progress bar. 145 * 146 * See [method@Gtk.ProgressBar.set_ellipsize]. 147 * 148 * Returns: `PangoEllipsizeMode` 149 */ 150 public PangoEllipsizeMode getEllipsize() 151 { 152 return gtk_progress_bar_get_ellipsize(gtkProgressBar); 153 } 154 155 /** 156 * Returns the current fraction of the task that’s been completed. 157 * 158 * Returns: a fraction from 0.0 to 1.0 159 */ 160 public double getFraction() 161 { 162 return gtk_progress_bar_get_fraction(gtkProgressBar); 163 } 164 165 /** 166 * Returns whether the progress bar is inverted. 167 * 168 * Returns: %TRUE if the progress bar is inverted 169 */ 170 public bool getInverted() 171 { 172 return gtk_progress_bar_get_inverted(gtkProgressBar) != 0; 173 } 174 175 /** 176 * Retrieves the pulse step. 177 * 178 * See [method@Gtk.ProgressBar.set_pulse_step]. 179 * 180 * Returns: a fraction from 0.0 to 1.0 181 */ 182 public double getPulseStep() 183 { 184 return gtk_progress_bar_get_pulse_step(gtkProgressBar); 185 } 186 187 /** 188 * Returns whether the `GtkProgressBar` shows text. 189 * 190 * See [method@Gtk.ProgressBar.set_show_text]. 191 * 192 * Returns: %TRUE if text is shown in the progress bar 193 */ 194 public bool getShowText() 195 { 196 return gtk_progress_bar_get_show_text(gtkProgressBar) != 0; 197 } 198 199 /** 200 * Retrieves the text that is displayed with the progress bar. 201 * 202 * The return value is a reference to the text, not a copy of it, 203 * so will become invalid if you change the text in the progress bar. 204 * 205 * Returns: the text 206 */ 207 public string getText() 208 { 209 return Str.toString(gtk_progress_bar_get_text(gtkProgressBar)); 210 } 211 212 /** 213 * Indicates that some progress has been made, but you don’t know how much. 214 * 215 * Causes the progress bar to enter “activity mode,” where a block 216 * bounces back and forth. Each call to [method@Gtk.ProgressBar.pulse] 217 * causes the block to move by a little bit (the amount of movement 218 * per pulse is determined by [method@Gtk.ProgressBar.set_pulse_step]). 219 */ 220 public void pulse() 221 { 222 gtk_progress_bar_pulse(gtkProgressBar); 223 } 224 225 /** 226 * Sets the mode used to ellipsize the text. 227 * 228 * The text is ellipsized if there is not enough space 229 * to render the entire string. 230 * 231 * Params: 232 * mode = a `PangoEllipsizeMode` 233 */ 234 public void setEllipsize(PangoEllipsizeMode mode) 235 { 236 gtk_progress_bar_set_ellipsize(gtkProgressBar, mode); 237 } 238 239 /** 240 * Causes the progress bar to “fill in” the given fraction 241 * of the bar. 242 * 243 * The fraction should be between 0.0 and 1.0, inclusive. 244 * 245 * Params: 246 * fraction = fraction of the task that’s been completed 247 */ 248 public void setFraction(double fraction) 249 { 250 gtk_progress_bar_set_fraction(gtkProgressBar, fraction); 251 } 252 253 /** 254 * Sets whether the progress bar is inverted. 255 * 256 * Progress bars normally grow from top to bottom or left to right. 257 * Inverted progress bars grow in the opposite direction. 258 * 259 * Params: 260 * inverted = %TRUE to invert the progress bar 261 */ 262 public void setInverted(bool inverted) 263 { 264 gtk_progress_bar_set_inverted(gtkProgressBar, inverted); 265 } 266 267 /** 268 * Sets the fraction of total progress bar length to move the 269 * bouncing block. 270 * 271 * The bouncing block is moved when [method@Gtk.ProgressBar.pulse] 272 * is called. 273 * 274 * Params: 275 * fraction = fraction between 0.0 and 1.0 276 */ 277 public void setPulseStep(double fraction) 278 { 279 gtk_progress_bar_set_pulse_step(gtkProgressBar, fraction); 280 } 281 282 /** 283 * Sets whether the progress bar will show text next to the bar. 284 * 285 * The shown text is either the value of the [property@Gtk.ProgressBar:text] 286 * property or, if that is %NULL, the [property@Gtk.ProgressBar:fraction] value, 287 * as a percentage. 288 * 289 * To make a progress bar that is styled and sized suitably for containing 290 * text (even if the actual text is blank), set [property@Gtk.ProgressBar:show-text] 291 * to %TRUE and [property@Gtk.ProgressBar:text] to the empty string (not %NULL). 292 * 293 * Params: 294 * showText = whether to show text 295 */ 296 public void setShowText(bool showText) 297 { 298 gtk_progress_bar_set_show_text(gtkProgressBar, showText); 299 } 300 301 /** 302 * Causes the given @text to appear next to the progress bar. 303 * 304 * If @text is %NULL and [property@Gtk.ProgressBar:show-text] is %TRUE, 305 * the current value of [property@Gtk.ProgressBar:fraction] will be displayed 306 * as a percentage. 307 * 308 * If @text is non-%NULL and [property@Gtk.ProgressBar:show-text] is %TRUE, 309 * the text will be displayed. In this case, it will not display the progress 310 * percentage. If @text is the empty string, the progress bar will still 311 * be styled and sized suitably for containing text, as long as 312 * [property@Gtk.ProgressBar:show-text] is %TRUE. 313 * 314 * Params: 315 * text = a UTF-8 string 316 */ 317 public void setText(string text) 318 { 319 gtk_progress_bar_set_text(gtkProgressBar, Str.toStringz(text)); 320 } 321 }